//
//  ButtonView.swift
//  KaMengApplication
//
//  Created by DUONIU_MAC on 2018/9/7.
//  Copyright © 2018年 DUONIU_MAC. All rights reserved.
//

import UIKit

class ButtonView: UIButton {

    fileprivate let arrowView = UIImageView()
    fileprivate let textLabel = UILabel()
    
    var image : UIImage! {
        didSet{
            arrowView.image = image
        }
    }
    
    var text : String! {
        didSet{
            textLabel.text = text
        }
    }
    
    init() {
        super.init(frame: .zero)
        
        arrowView.image = #imageLiteral(resourceName: "bottom_arrow")
        self.addSubview(arrowView)
        
        textLabel.font = UIFont.systemFont(ofSize: RATIO(maxNum: 16))
        self.addSubview(textLabel)
        
        textLabel.snp.makeConstraints { (make) in
            make.centerX.equalToSuperview().offset(RATIO_H(maxNum: -11))
            make.centerY.equalToSuperview()
            make.width.greaterThanOrEqualTo(10)
            make.height.greaterThanOrEqualTo(10)
        }
        
        arrowView.snp.makeConstraints { (make) in
            make.centerY.equalTo(textLabel)
            make.left.equalTo(textLabel.snp.right).offset(RATIO(maxNum: 2))
            make.width.height.equalTo(RATIO_H(maxNum: 20))
        }
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
}
